{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Introduction\n",
    "-----\n",
    "You (an electrical engineer) wish to determine the resistance of an electrical component by using Ohm's law. You remember from your high school circuit classes that $$V = RI$$ where $V$ is the voltage in volts, $R$ is resistance in ohms, and $I$ is electrical current in amperes. Using a multimeter, you collect the following data:\n",
    "\n",
    "| Current (A) | Voltage (V) |\n",
    "|-------------|-------------|\n",
    "| 0.2         | 1.23        |\n",
    "| 0.3         | 1.38        |\n",
    "| 0.4         | 2.06        |\n",
    "| 0.5         | 2.47        |\n",
    "| 0.6         | 3.17        |\n",
    "\n",
    "Your goal is to \n",
    "1. Fit a line through the origin (i.e., determine the parameter $R$ for $y = Rx$) to this data by using the method of least squares. You may assume that all measurements are of equal importance. \n",
    "2. Consider what the best estimate of the resistance is, in ohms, for this component.\n",
    "\n",
    "## Getting Started\n",
    "----\n",
    "\n",
    "First we will import the neccesary Python modules and load the current and voltage measurements into numpy arrays:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from numpy.linalg import inv\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# Store the voltage and current data as column vectors.\n",
    "I = np.mat([0.2, 0.3, 0.4, 0.5, 0.6]).T\n",
    "V = np.mat([1.23, 1.38, 2.06, 2.47, 3.17]).T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can plot the measurements - can you see the linear relationship between current and voltage?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAEKCAYAAAAB0GKPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAH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GWbeT3U/XHjJo/TM1lg8A3hARu82mlxeQ6kfi76L4719/9WdLOpHsMdYr8v0dBDzEnwvGIfk2ZqXwGIaNV7cDB0vqHmiQ9FpJfwM8QnaUcHA+Mc1bRrDf24ALqva5x6mmQbaTnaLaQz4F5wRJA0VjHvC5gcejR8QUYIqkY/L1rwbuH0GsZiPigmHjUmSPaX4X8Nb8stoNwGXA/4uIR4Hvk/3j+31g7Qh2/XGgI59idCPwjwVxPAH8XNL9wwx63waclr+fS3ZlV7Ul/HmguwsYj1O/Wp348eZmTSyfA/zCiDi3oN/BwE+B0yJiZ12Cs3HHRxhmTSwi1gB3DL7nYwhHAxe7WFiZfIRhZmZJfIRhZmZJXDDMzCyJC4aZmSVxwTAzsyQuGGZmluT/AzlAud9x2CMNAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(np.asarray(I), np.asarray(V))\n",
    "\n",
    "plt.xlabel('Current (A)')\n",
    "plt.ylabel('Voltage (V)')\n",
    "plt.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Estimating the Slope Parameter\n",
    "----\n",
    "Let's try to estimate the slope parameter $R$ (i.e., the resistance) using the least squares formulation from Module 1, Lesson 1 - \"The Squared Error Criterion and the Method of Least Squares\":\n",
    "\n",
    "\\begin{align}\n",
    "\\hat{R} = \\left(\\mathbf{H}^T\\mathbf{H}\\right)^{-1}\\mathbf{H}^T\\mathbf{y}\n",
    "\\end{align}\n",
    "\n",
    "If we know that we're looking for the slope parameter $R$, how do we define the matrix $\\mathbf{H}$ and vector $\\mathbf{y}$?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The slope parameter (i.e., resistance) for the best-fit line is:\n",
      "5.13444444444\n"
     ]
    }
   ],
   "source": [
    "# Define the H matrix, what does it contain?\n",
    "# H = ...\n",
    "H = I\n",
    "y = V\n",
    "\n",
    "# Now estimate the resistance parameter.\n",
    "# R = ... \n",
    "R = inv(H.T * H) * H.T * y\n",
    "R = R[0, 0]\n",
    "\n",
    "print('The slope parameter (i.e., resistance) for the best-fit line is:')\n",
    "print(R)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plotting the Results\n",
    "----\n",
    "Now let's plot our result. How do we relate our linear parameter fit to the resistance value in ohms?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3Xd4VHX2x/H3oQQCoZcQQgkdaQqhiFiAVcFKVWFdu2JdXQsCVpR1RVl1de1d1DWuEAERwUJAZEUFhIQEAqETkE5IIAkp5/fHDPnFGJJJuZm5yXk9zzzMvfd773wYwpzcMueKqmKMMcYAVPN3AGOMMYHDioIxxpg8VhSMMcbksaJgjDEmjxUFY4wxeawoGGOMyWNFwRhjTB4rCsYYY/JYUTDGGJOnhr8DlFTTpk01IiKiVOseO3aMunXrlm8gB7kpr5uygrvyuikruCuvm7JC2fKuWrXqgKo2K3agqrrqERkZqaUVExNT6nX9wU153ZRV1V153ZRV1V153ZRVtWx5gZXqw2esHT4yxhiTx4qCMcaYPFYUjDHG5LGiYIwxJo8VBWOMMXmsKBhjjMljRcEYY0weKwrGGBPgsnJyeXVJEltSchx/Ldd9o9kYY6qSdckpTJodS/zuo1zcriY3Ovx6VhSMMSYAZWTl8O/Fm3h96RYa1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fiYiLwJfqOq3xYwbBfRR1UcrJpmpimxPwRj/+wdQx4dxNYDnHM5iqjjbUzDGGJPH9hSMMcbksaJgjDEmjxUFY4wxeawoGGOMyWNFwRhjTJ7/A54RR2niMf5OAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "I_line = np.arange(0, 0.8, 0.1)\n",
    "V_line = R*I_line\n",
    "\n",
    "plt.scatter(np.asarray(I), np.asarray(V))\n",
    "plt.plot(I_line, V_line)\n",
    "plt.xlabel('current (A)')\n",
    "plt.ylabel('voltage (V)')\n",
    "plt.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you have implemented the estimation steps correctly, the slope parameter $\\hat{R}$ should be close to the actual resistance value of $R = 5~\\Omega$. However, the estimated value will not match the true resistance value exactly, since we have only a limited number of noisy measurements."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
